package cz.muni.fi.hauntedhouses.service.impl;

import cz.muni.fi.hauntedhouses.dao.HumanDAO;
import cz.muni.fi.hauntedhouses.service.HumanService;
import cz.muni.fi.hauntedhouses.to.HumanTO;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Martin Vala, 359917
 */
@Service
@Transactional
public class HumanServiceImpl implements HumanService {
    
    @Autowired
    private HumanDAO humanDao;
    
    @Override
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public void create(HumanTO human) {
            humanDao.create(human);
    }

    @Override
    public List<HumanTO> findAll() {
        return humanDao.findAll();
    }

    @Override
    public List<HumanTO> findByName(String name) {
        return humanDao.findByName(name);
    }

    @Override
    public HumanTO get(Long id) {
        return humanDao.get(id);
    }

    @Override
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public void remove(HumanTO human) {
        humanDao.remove(human);
    }

    @Override
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public void update(HumanTO human) {
        humanDao.update(human);
    }
}